home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
oper_sys
/
oasis
/
oasis1-1.lha
/
oasis-1.1
/
find.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-01
|
6KB
|
252 lines
/*==========================================================================*
Oasis Alpha Version 1.1 (C) Copyright 1992 Fah-Chun Cheong
Revised: 5/1/92 by: fcc@eecs.umich.edu and The University of Michigan
------------------------------------------------------------------------
Permission to use, copy, modify, distribute, sell and resell Oasis Alpha
software and its documentation for any purpose and without fee is hereby
granted, provided that the authorship be appropriately credited and
acknowledged, and that the above copyright notice appear in all copies
and both the copyright notice and this permission notice appear in
supporting documentation. The author makes no representations about the
suitability of this software for any purpose. It is provided "as is"
without express or implied warranty. Oasis Alpha is free, caveat emptor!
------------------------------------------------------------------------
To request Oasis Alpha source code: oasis-alpha-request@eecs.umich.edu
To enroll in the mailing list: oasis-alpha-request@eecs.umich.edu
To send bug reports: oasis-alpha-bugs@eecs.umich.edu
To discuss openly all matters Oasis: oasis-alpha@eecs.umich.edu
*==========================================================================*/
#include "parser.h"
#include "par.h"
Spec *find_spec(name, specs)
char *name;
Spec *specs;
{
for (; specs; specs = specs->next)
if (same(name, specs->name))
return specs;
return NUL;
}
Spec *find_base(name, specs)
char *name;
Spec *specs;
{
for (; specs; specs = specs->base)
if (same(name, specs->name))
return specs;
return NUL;
}
Gene *find_gene(name, genes)
char *name;
Gene *genes;
{
for (; genes; genes = genes->next)
if (same(name, genes->name))
return genes;
return NUL;
}
Cond *find_cond(name, conds)
char *name;
Cond *conds;
{
for (; conds; conds = conds->next)
if (same(name, conds->name))
return conds;
return NUL;
}
Cst *find_cst(name, csts)
char *name;
Cst *csts;
{
for (; csts; csts = csts->next)
if (same(name, csts->name))
return csts;
return NUL;
}
Att *find_att(name, level, prot, atts)
char *name;
int level;
int prot;
Att *atts;
{
for (; atts; atts = atts->next)
if (same(name, atts->name) && seen(level, atts->level, prot, atts->prot))
return atts;
return NUL;
}
Met *find_met(name, level, prot, mets)
char *name;
int level;
int prot;
Met *mets;
{
for (; mets; mets = mets->next)
if (same(name, mets->name) && seen(level, mets->level, prot, mets->prot))
return mets;
return NUL;
}
Arg *find_arg(name, args)
char *name;
Arg *args;
{
for (; args; args = args->next)
if (same(name, args->name))
return args;
return NUL;
}
Imp *find_imp(name, imps)
char *name;
Imp *imps;
{
for (; imps; imps = imps->next)
if (same(name, imps->name))
return imps;
return NUL;
}
Head *find_head(name, rules, rule)
char *name;
Rule *rules;
Rule *rule;
{
if (rule && same(name, rule->head->name))
return NUL;
for (; rules; rules = rules->next)
if (same(name, rules->head->name))
return rules->head;
return NUL;
}
Var *find_var(name, vars)
char *name;
Var *vars;
{
for (; vars; vars = vars->next)
if (same(name, vars->name))
return vars;
return NUL;
}
Spec *lookup_spec(name, specs, levelp, sizep, basep, genesp, condsp, cstsp, attsp, metsp)
char *name;
Spec *specs;
int *levelp;
int *sizep;
Spec **basep;
Gene **genesp;
Cond **condsp;
Cst **cstsp;
Att **attsp;
Met **metsp;
{
if (specs = find_spec(name, specs)) {
*levelp = specs->level;
*sizep = specs->size;
*genesp = specs->genes;
*condsp = specs->conds;
*cstsp = specs->csts;
*attsp = specs->atts;
*metsp = specs->mets;
}
else {
*levelp = 0;
*sizep = 0;
*genesp = NUL;
*condsp = NUL;
*cstsp = NUL;
*attsp = NUL;
*metsp = NUL;
}
return *basep = specs;
}
Spec *lookup_base(name, specs, levelp, metsp)
char *name;
Spec *specs;
int *levelp;
Met **metsp;
{
if (specs = find_base(name, specs)) {
*levelp = specs->level;
*metsp = specs->mets;
}
else {
*levelp = 0;
*metsp = NUL;
}
return specs;
}
Gene *lookup_gene(name, genes, goffp)
char *name;
Gene *genes;
int *goffp;
{
if (genes = find_gene(name, genes))
*goffp = genes->goff;
else *goffp = 0;
return genes;
}
Cond *lookup_cond(name, conds, coffp)
char *name;
Cond *conds;
int *coffp;
{
if (conds = find_cond(name, conds))
*coffp = conds->coff;
else *coffp = 0;
return conds;
}
Att *lookup_att(name, level, prot, atts, aoffp, typep)
char *name;
int level;
int prot;
Att *atts;
int *aoffp;
Type **typep;
{
if (atts = find_att(name, level, prot, atts)) {
*aoffp = atts->aoff;
*typep = atts->type;
}
else {
*aoffp = 0;
*typep = Bot;
}
return atts;
}
Met *lookup_met(name, level, prot, mets, moffp, protp, argsp)
char *name;
int level;
int prot;
Met *mets;
int *moffp;
int *protp;
Arg **argsp;
{
if (mets = find_met(name, level, prot, mets)) {
*moffp = mets->moff;
*protp = mets->prot;
*argsp = mets->args;
}
else {
*moffp = 0;
*protp = PUBLIC;
*argsp = NUL;
}
return mets;
}